--[[
	
	Name: Advanced Questbook
	By: Crypton

]]
function AdvQuestBookDumper_QuestAccept(AQB_ADDQUEST_NAME, AQB_ADDQUEST_ID)
	local AQB_ADD;
	local AQB_TOTALQUESTS = GetNumQuestBookButton_QuestBook();
	for AQB_ADD = 1, AQB_TOTALQUESTS do
		local AQB_INDEX, AQB_CATID, AQB_NAME, AQB_TRACK, AQB_LEVEL, AQB_DAILY = GetQuestInfo(AQB_ADD);
		local AQB_NAME = string.gsub(AQB_NAME, "%-+", "");
		AQB_NAME = string.gsub(AQB_NAME, "%s%s+", " ");
		if (string.find(AQB_NAME, AQB_ADDQUEST_NAME)) then
			if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests, true)) then
				AdvQuestBook_Dumped_Quests = {};
			end
			SaveVariables("AdvQuestBook_Dumped_Quests");
			if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL], true)) then
				AdvQuestBook_Dumped_Quests[AQB_LOCAL] = {};
			end
			SaveVariables("AdvQuestBook_Dumped_Quests");
			if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADDQUEST_NAME], true)) then
				ViewQuest_QuestBook(AQB_ADD);
				local AQB_QNPCID = QuestDetail_GetQuestNPC();
				local AQB_QUEST_NPCID, AQB_QUEST_NPCNAME, AQB_QUEST_NPCMAPID, AQB_QUEST_NPCX, AQB_QUEST_NPCY = "", "", "", "", "";
				if (not AQB_IsEmpty(AQB_QNPCID, true)) then
					AQB_QUEST_NPCID, AQB_QUEST_NPCNAME, AQB_QUEST_NPCMAPID, AQB_QUEST_NPCX, AQB_QUEST_NPCY = NpcTrack_GetNpc(NpcTrack_SearchNpcByDBID(AQB_QNPCID));
				end
				local AQB_RNPCID = QuestDetail_GetRequestQuestNPC();
				local AQB_QUEST_RNPCID, AQB_QUEST_RNPCNAME, AQB_QUEST_RNPCMAPID, AQB_QUEST_RNPCX, AQB_QUEST_RNPCY = "", "", "", "", "";
				if (not AQB_IsEmpty(AQB_RNPCID, true)) then
					AQB_QUEST_RNPCID, AQB_QUEST_RNPCNAME, AQB_QUEST_RNPCMAPID, AQB_QUEST_RNPCX, AQB_QUEST_RNPCY = NpcTrack_GetNpc(NpcTrack_SearchNpcByDBID(AQB_RNPCID));
				end
				local AQB_QUEST_EXP, AQB_QUEST_TP, AQB_QUEST_GOLD = GetQuestExp_QuestDetail(), GetQuestTP_QuestDetail(), GetQuestMoney_QuestDetail();
				if (AQB_IsEmpty(AQB_QUEST_EXP, true)) then
					local AQB_QUEST_EXP = 0;
				end
				if (AQB_IsEmpty(AQB_QUEST_TP, true)) then
					local AQB_QUEST_TP = 0;
				end
				if (AQB_IsEmpty(AQB_QUEST_GOLD, true)) then
					local AQB_QUEST_GOLD = 0;
				end
				local AQB_QUEST_SHORTTEXT = GetQuestDesc_QuestDetail(AQB_ADD);
				AQB_QUEST_SHORTTEXT = string.gsub(AQB_QUEST_SHORTTEXT, "%s%s+", " ");
				AQB_QUEST_SHORTTEXT = string.gsub(AQB_QUEST_SHORTTEXT, "\n+", " ");
				AQB_QUEST_SHORTTEXT = string.gsub(AQB_QUEST_SHORTTEXT, "%\+", " ");
				local AQB_QUEST_LONGTEXT = GetQuestDetail_QuestDetail(AQB_ADD);
				AQB_QUEST_LONGTEXT = string.gsub(AQB_QUEST_LONGTEXT, "%s%s+", " ");
				AQB_QUEST_LONGTEXT = string.gsub(AQB_QUEST_LONGTEXT, "\n+", " ");
				AQB_QUEST_LONGTEXT = string.gsub(AQB_QUEST_LONGTEXT, "%\+", " ");
				AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADDQUEST_NAME] = {
					["id"] = AQB_ADDQUEST_ID,
					["turnedin"] = false,
					["info"] = {
						["index"] = AQB_INDEX,
						["catalogID"] = AQB_CATID,
						["track"] = AQB_TRACK,
						["level"] = AQB_LEVEL,
						["daily"] = AQB_DAILY,
						["descshort"] = AQB_QUEST_SHORTTEXT,
						["desclong"] = AQB_QUEST_LONGTEXT,
					},
					["start"] = {
						["npcid"] = AQB_QUEST_NPCID,
						["npc"] = AQB_QUEST_NPCNAME,
						["mapid"] = AQB_QUEST_NPCMAPID,
						["x"] = AQB_QUEST_NPCX,
						["y"] = AQB_QUEST_NPCY,
					},
					["end"] = {
						["npcid"] = AQB_QUEST_RNPCID,
						["npc"] = AQB_QUEST_RNPCNAME,
						["mapid"] = AQB_QUEST_RNPCMAPID,
						["x"] = AQB_QUEST_RNPCX,
						["y"] = AQB_QUEST_RNPCY,
					},
					["rewards"] = {
						["Exp"] = AQB_QUEST_EXP,
						["TP"] = AQB_QUEST_TP,
						["Gold"] = AQB_QUEST_GOLD,
					},
					["items"] = {
					},
					["locations"] = {
					},
				};
				SaveVariables("AdvQuestBook_Dumped_Quests");
			end
		end
	end
	return;
end

function AdvQuestBookDumper_QuestUpdate(AQB_ADD_QUEST, AQB_ADD_MAP, AQB_ADD_X, AQB_ADD_Y, AQB_ADD_ITEM, AQB_ADD_VAL)
	if (not AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST], true)) then
		if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM], true)) then
			AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM] = {};
		end
		if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM]["total"], true)) then
			AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM]["total"] = AQB_ADD_VAL;
		end
		if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM]["locations"], true)) then
			AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM]["locations"] = {};
		end
		for i = 1, AQB_ADD_VAL do
			if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM]["locations"][i], true)) then
				AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_QUEST]["items"][AQB_ADD_ITEM]["locations"][i] = {
					["mapid"] = AQB_ADD_MAP,
					["x"] = AQB_ADD_X,
					["y"] = AQB_ADD_Y
				};
				SaveVariables("AdvQuestBook_Dumped_Quests");
				break;
			end
		end
	end
	return;
end

function AdvQuestBookDumper_QuestMet(AQB_ADD_MET, AQB_ADD_MAP, AQB_ADD_X, AQB_ADD_Y)
	if (not AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_MET], true)) then
		if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_MET]["locations"], true)) then
			AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_MET]["locations"] = {};
		end
		for i = 1, 5 do
			if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_MET]["locations"][i], true)) then
				AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_ADD_MET]["locations"][i] = {
					["mapid"] = AQB_ADD_MAP,
					["x"] = AQB_ADD_X,
					["y"] = AQB_ADD_Y
				};
				SaveVariables("AdvQuestBook_Dumped_Quests");
				break;
			end
		end
	end
	return;
end

function AdvQuestBookDumper_QuestComplete(AQB_QUEST_COMPLETED)
	if (not AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_QUEST_COMPLETED], true)) then
		AdvQuestBook_Dumped_Quests[AQB_LOCAL][AQB_QUEST_COMPLETED]["turnedin"] = true;
		if (AdvQuestBook_Config["settings"][14]["value"]) then
			DEFAULT_CHAT_FRAME:AddMessage("|cFFffffff"..AQB_ADDON_NAME..":|r "..AQB_QUEST_COMPLETED..AQB_SSTRINGS["AQB_COMPLETE1_TEXT"].." - "..AQB_ISTRINGS["AQB_UPLOAD1"].." |cFFffffffSaveVariables.lua|r "..AQB_ISTRINGS["AQB_TO"].." |cFFffffffhttp://rom.gamedata.us|r "..AQB_ISTRINGS["AQB_UPLOAD2"]..".");
		end
	end
	return;
end

function AdvQuestBookDumper_OnLoad(this)
	this:RegisterEvent("VARIABLES_LOADED");
	this:RegisterEvent("SYSTEM_MESSAGE");
	this:RegisterEvent("ADDNEW_QUESTBOOK");
	this:RegisterEvent("QUEST_COMPLETE");
end

function AdvQuestBookDumper_EventHandler(this, event, aqd1, aqd2)
	if (event == "VARIABLES_LOADED") then
		if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests, true)) then
			AdvQuestBook_Dumped_Quests = {};
		end
		SaveVariables("AdvQuestBook_Dumped_Quests");
		if (AQB_IsEmpty(AdvQuestBook_Dumped_Quests[AQB_LOCAL], true)) then
			AdvQuestBook_Dumped_Quests[AQB_LOCAL] = {};
		end
		SaveVariables("AdvQuestBook_Dumped_Quests");
		AQB_DEBUG_LANG_STRINGS = {
		[AQB_LOCAL] = {};
		}
		if (AQB_DEBUG_GAMESTRINGS) then
			SaveVariables("AQB_DEBUG_LANG_STRINGS");
		end
	end
	if (AdvQuestBook_Config["settings"][8]["value"]) then
		if (event == "QUEST_COMPLETE") then
			AQB_LAST_FINISHQUEST = aqd2;
			if (AQB_DEBUG_GAMESTRINGS) then
				AQB_DEBUG_MESSAGE("AQB_LAST_FINISHQUEST: "..aqd2);
				table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "AQB_LAST_FINISHQUEST: "..aqd2);
				SaveVariables("AQB_DEBUG_LANG_STRINGS");
			end
		elseif (event == "ADDNEW_QUESTBOOK") then
			AQB_LAST_ADDQUEST = aqd1;
			if (AQB_DEBUG_GAMESTRINGS) then
				AQB_DEBUG_MESSAGE("AQB_LAST_ADDQUEST: "..aqd1);
				table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "AQB_LAST_ADDQUEST: "..aqd1);
				SaveVariables("AQB_DEBUG_LANG_STRINGS");
			end
		elseif (event == "SYSTEM_MESSAGE") then
			if (string.find(aqd1, AQB_SSTRINGS["AQB_QUEST_ABANDON"])) then
				local AQB_QUEST_ABANDON = string.gsub(aqd1, AQB_SSTRINGS["AQB_QUEST_ABANDON"], "");
				--[[ Begin Fix for DE Dumping ]]
				if (AQB_LOCAL == "DE") then
					AQB_QUEST_ABANDON = string.gsub(AQB_QUEST_ABANDON, "\"+", "");
				end
				--[[ End Fix for DE Dumping ]]
				if (AQB_DEBUG_GAMESTRINGS) then
					AQB_DEBUG_MESSAGE("Abandoned: "..AQB_QUEST_ABANDON);
					table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "Abandoned: "..AQB_QUEST_ABANDON);
					SaveVariables("AQB_DEBUG_LANG_STRINGS");
				end
			elseif (string.find(aqd1, AQB_SSTRINGS["AQB_QUEST_ACCEPT"])) then
				local AQB_QUEST_ACCEPT = string.gsub(aqd1, AQB_SSTRINGS["AQB_QUEST_ACCEPT"], "");
				AQB_QUEST_ACCEPT = string.gsub(AQB_QUEST_ACCEPT, "%-+", "");
				AQB_QUEST_ACCEPT = string.gsub(AQB_QUEST_ACCEPT, "%s%s+", " ");
				--[[ Begin Fix for DE Dumping ]]
				if (AQB_LOCAL == "DE") then
					AQB_QUEST_ACCEPT = string.gsub(AQB_QUEST_ACCEPT, "\"+", "");
				end
				--[[ End Fix for DE Dumping ]]
				--[[ Begin Fix for ES Dumping ]]
				if (AQB_LOCAL == "ES") then
					AQB_QUEST_ACCEPT = AdvQuestBookGSubUTF8(AQB_QUEST_ACCEPT, 9, string.len(AQB_QUEST_ACCEPT));
					AQB_QUEST_ACCEPT = string.gsub(AQB_QUEST_ACCEPT, AQB_SSTRINGS["AQB_QUEST_ACCEPT2"], "");
				end
				--[[ End Fix for ES Dumping ]]
				if (AQB_DEBUG_GAMESTRINGS) then
					AQB_DEBUG_MESSAGE("Accepted: "..AQB_QUEST_ACCEPT);
					table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "Accepted: "..AQB_QUEST_ACCEPT);
					SaveVariables("AQB_DEBUG_LANG_STRINGS");
				end
				if (AQB_IsEmpty(AQBQbyName[AQB_QUEST_ACCEPT], true)) then
					if (AdvQuestBook_Config["settings"][14]["value"]) then
						DEFAULT_CHAT_FRAME:AddMessage("|cFFffffff"..AQB_ADDON_NAME..":|r "..AQB_ISTRINGS["AQB_NEW"].." "..AQB_ISTRINGS["AQB_QUEST"].." "..AQB_ISTRINGS["AQB_DUMPED"].." "..AQB_ISTRINGS["AQB_FOR"].." "..AQB_QUEST_ACCEPT..".");
					end
					AdvQuestBookDumper_QuestAccept(AQB_QUEST_ACCEPT, AQB_LAST_ADDQUEST);
				end

			elseif (string.find(aqd1, AQB_SSTRINGS["AQB_QUEST_MET"])) then
				local AQB_QUPD_MAP = GetCurrentWorldMapID();
				local AQB_QUPD_X, AQB_QUPD_Y = GetPlayerWorldMapPos();
				--[[ Begin Fix for DE Dumping ]]
				local AQB_MET_UPDATE = aqd1;
				if (AQB_LOCAL == "DE") then
					AQB_MET_UPDATE = string.match(AQB_MET_UPDATE, "\"(.+)\"");
					AQB_MET_UPDATE = string.gsub(AQB_MET_UPDATE, "\"+", "");
				else
					AQB_MET_UPDATE = string.gsub(AQB_MET_UPDATE, AQB_SSTRINGS["AQB_QUEST_MET"], "");
				end
				--[[ End Fix for DE Dumping ]]


				AQB_MET_UPDATE = string.gsub(AQB_MET_UPDATE, "%-+", "");
				AQB_MET_UPDATE = string.gsub(AQB_MET_UPDATE, "%s%s+", " ");
				if (AQB_DEBUG_GAMESTRINGS) then
					AQB_DEBUG_MESSAGE("Met: "..AQB_MET_UPDATE);
					table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "Met: "..AQB_MET_UPDATE);
					SaveVariables("AQB_DEBUG_LANG_STRINGS");
				end
				if (AQB_IsEmpty(AQBQbyName[AQB_MET_UPDATE], true)) then
					AdvQuestBookDumper_QuestMet(AQB_MET_UPDATE, AQB_QUPD_MAP, AQB_QUPD_X, AQB_QUPD_Y);
				end
			elseif (string.find(aqd1, AQB_SSTRINGS["AQB_MATCH_AMOUNT1"])) then
				local AQB_QUPD_MAP = GetCurrentWorldMapID();
				local AQB_QUPD_X, AQB_QUPD_Y = GetPlayerWorldMapPos();
				local AQB_QUEST_UPDATED = string.gsub(aqd1, AQB_SSTRINGS["AQB_QUEST_COMPLETE1"], "");
				AQB_QUEST_UPDATED = string.gsub(AQB_QUEST_UPDATED, AQB_SSTRINGS["AQB_QUEST_UPDATED"], "");
				AQB_QUEST_UPDATED = string.gsub(AQB_QUEST_UPDATED, "%-+", "");
				AQB_QUEST_UPDATED = string.gsub(AQB_QUEST_UPDATED, "%s%s+", " ");
				local AQB_UPDATE_ITEM = string.gsub(aqd1, AQB_SSTRINGS["AQB_QUEST_COMPLETE1"], "");
				AQB_UPDATE_ITEM = string.gsub(AQB_UPDATE_ITEM, AQB_SSTRINGS["AQB_UPDATE_ITEM2"], "");
				AQB_UPDATE_ITEM = string.gsub(AQB_UPDATE_ITEM, AQB_SSTRINGS["AQB_UPDATE_ITEM1"], "");
				local AQB_UPDATE_AMOUNT = string.gsub(aqd1, AQB_SSTRINGS["AQB_QUEST_COMPLETE1"], "");
				AQB_UPDATE_AMOUNT = string.gsub(AQB_UPDATE_AMOUNT, AQB_SSTRINGS["AQB_UPDATE_AMOUNT"], "");
				local AQB_UPDATE_AMOUNT1 = string.gsub(AQB_UPDATE_AMOUNT, AQB_SSTRINGS["AQB_UPDATE_AMOUNT1"], "");
				local AQB_UPDATE_AMOUNT2 = string.gsub(AQB_UPDATE_AMOUNT, AQB_SSTRINGS["AQB_UPDATE_AMOUNT2"], "");
				if (AQB_DEBUG_GAMESTRINGS) then
					AQB_DEBUG_MESSAGE("Update: "..AQB_UPDATE_AMOUNT1.." of "..AQB_UPDATE_AMOUNT2.." "..AQB_UPDATE_ITEM);
					table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "Update: "..AQB_UPDATE_AMOUNT1.." of "..AQB_UPDATE_AMOUNT2.." "..AQB_UPDATE_ITEM);
					SaveVariables("AQB_DEBUG_LANG_STRINGS");
				end
				if (AQB_IsEmpty(AQBQbyName[AQB_QUEST_UPDATED], true)) then
					AdvQuestBookDumper_QuestUpdate(AQB_QUEST_UPDATED, AQB_QUPD_MAP, AQB_QUPD_X, AQB_QUPD_Y, AQB_UPDATE_ITEM, AQB_UPDATE_AMOUNT2);
				end
			elseif (aqd2 ~= nil and aqd2 == AQB_LAST_FINISHQUEST) then
				if (string.find(aqd1, AQB_SSTRINGS["AQB_QUEST_COMPLETE2"])) then
					local AQB_QUEST_COMPLETE = aqd1;
					--[[ Begin Fix for FR Dumping ]]
					if (AQB_LOCAL == "FR") then
						if (not string.find(aqd1, AQB_SSTRINGS["AQB_QUEST_COMPLETE2"].."(.+)"..AQB_SSTRINGS["AQB_QUEST_COMPLETE3"])) then
							return;
						end
					end

					--[[ Begin Fix for ES Dumping ]]
					if (AQB_LOCAL == "ES") then
						AQB_QUEST_COMPLETE = AdvQuestBookGSubUTF8(AQB_QUEST_COMPLETE, 9, string.len(AQB_QUEST_COMPLETE));
						AQB_QUEST_COMPLETE = string.gsub(AQB_QUEST_COMPLETE, AQB_SSTRINGS["AQB_QUEST_ACCEPT2"], "");
					end
					--[[ End Fix for ES Dumping ]]

					--[[ End Fix for FR Dumping ]]
					AQB_QUEST_COMPLETE = string.gsub(AQB_QUEST_COMPLETE, AQB_SSTRINGS["AQB_QUEST_COMPLETE2"], "");
					AQB_QUEST_COMPLETE = string.gsub(AQB_QUEST_COMPLETE, "%-+", "");
					AQB_QUEST_COMPLETE = string.gsub(AQB_QUEST_COMPLETE, "%s%s+", " ");
					--[[ Begin Fix for DE Dumping ]]
					if (AQB_LOCAL == "DE") then
						AQB_QUEST_COMPLETE = string.gsub(AQB_QUEST_COMPLETE, "\"+", "");
					end
					--[[ End Fix for DE Dumping ]]
					--[[ Begin Fix for FR Dumping ]]
					if (AQB_LOCAL == "FR") then
						AQB_QUEST_COMPLETE = string.gsub(AQB_QUEST_COMPLETE, AQB_SSTRINGS["AQB_QUEST_COMPLETE3"], "");
					end
					--[[ End Fix for FR Dumping ]]

					if (AQB_DEBUG_GAMESTRINGS) then
						AQB_DEBUG_MESSAGE("Completed: "..AQB_QUEST_COMPLETE);
						table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], AQB_QUEST_COMPLETE);
						SaveVariables("AQB_DEBUG_LANG_STRINGS");
					end
					AdvQuestBookDumper_QuestComplete(AQB_QUEST_COMPLETE);
				end
			elseif (string.find(aqd1, AQB_SSTRINGS["AQB_MATCH_AMOUNT2"])) then
				local AQB_QUPD_MAP = GetCurrentWorldMapID();
				local AQB_QUPD_X, AQB_QUPD_Y = GetPlayerWorldMapPos();
				local AQB_QUEST_UPDATED = string.gsub(aqd1, AQB_SSTRINGS["AQB_QUEST_UPDATED"], "");
				AQB_QUEST_UPDATED = string.gsub(AQB_QUEST_UPDATED, "%-+", "");
				AQB_QUEST_UPDATED = string.gsub(AQB_QUEST_UPDATED, "%s%s+", " ");
				local AQB_UPDATE_ITEM = string.gsub(aqd1, AQB_SSTRINGS["AQB_UPDATE_ITEM2"], "");
				AQB_UPDATE_ITEM = string.gsub(AQB_UPDATE_ITEM, AQB_SSTRINGS["AQB_UPDATE_ITEM1"], "");
				local AQB_UPDATE_AMOUNT = string.gsub(aqd1, AQB_SSTRINGS["AQB_UPDATE_AMOUNT"], "");
				local AQB_UPDATE_AMOUNT1 = string.gsub(AQB_UPDATE_AMOUNT, AQB_SSTRINGS["AQB_UPDATE_AMOUNT1"], "");
				local AQB_UPDATE_AMOUNT2 = string.gsub(AQB_UPDATE_AMOUNT, AQB_SSTRINGS["AQB_UPDATE_AMOUNT2"], "");
				if (AQB_DEBUG_GAMESTRINGS) then
					AQB_DEBUG_MESSAGE("Update: "..AQB_UPDATE_AMOUNT1.." of "..AQB_UPDATE_AMOUNT2.." "..AQB_UPDATE_ITEM);
					table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "Update: "..AQB_UPDATE_AMOUNT1.." of "..AQB_UPDATE_AMOUNT2.." "..AQB_UPDATE_ITEM);
					SaveVariables("AQB_DEBUG_LANG_STRINGS");
				end
				if (AQB_IsEmpty(AQBQbyName[AQB_QUEST_UPDATED], true)) then
					AdvQuestBookDumper_QuestUpdate(AQB_QUEST_UPDATED, AQB_QUPD_MAP, AQB_QUPD_X, AQB_QUPD_Y, AQB_UPDATE_ITEM, AQB_UPDATE_AMOUNT2);
				end
			else
				if (AQB_DEBUG_GAMESTRINGS) then
					local evstring = AdvQuestBook_DebugArgs(event, aqd1, aqd2, 0, 0);
					if (evstring ~= nil) then
						table.insert(AQB_DEBUG_LANG_STRINGS[AQB_LOCAL], "EVString:"..evstring);
						SaveVariables("AQB_DEBUG_LANG_STRINGS");
					end
				end
			end
		end
	end
end
